package com.lx.java8;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
  *@Author: Mone xia
  *@Description
  *@Date Created in 下午 5:11 2017/12/8 0008
  *@Modified By:
  */
public class Concurrency {

    private List<String> concurrencyList = new ArrayList<>();
    public Concurrency() {
        init();
    }
    private void init() {
        initStringList();
    }
    private void initStringList() {
        concurrencyList.add("zzz1");
        concurrencyList.add("aaa2");
        concurrencyList.add("aaa3");
    }
    @Test
    public void test1(){
        // 随机生成一条的整数数据流
        // 我们只要10个随机整数
        //串行操作
        Stream stream=concurrencyList.stream();
        //并行操作
        Stream parallelStream=concurrencyList.parallelStream();
        IntStream range =new Random().ints().limit(10);
        range.forEach(System.out::println);
    }
    @Test
    public void test2(){
        // 随机生成一条的整数数据流
        // 我们只要10个随机整数
        IntStream range =new Random().ints().limit(10);
        range.forEach(System.out::println);
    }

    @Test
    public void test3(){
        concurrencyList.stream().filter(p ->p.startsWith("a")).forEach(System.out::println);
    }
    @Test
    public void test4(){
        concurrencyList.stream()
                .filter(p ->p.startsWith("a"))
                .map(p ->new User());
    }
}


















